package cur.nature.framework.core.log;

import ch.qos.logback.classic.pattern.LineOfCallerConverter;
import ch.qos.logback.classic.spi.ILoggingEvent;
import cur.nature.framework.core.thread.MyThreadLocal;
import org.slf4j.MDC;

import java.util.Optional;

/**
 * @author wujian
 * @Date 2018-07-16
 */
public class TraceIdConverter extends LineOfCallerConverter {

    @Override
    public String convert(ILoggingEvent le) {
        final Object traceId = MyThreadLocal.getCurrentThread().get(MyThreadLocal.TRACE_ID);
        return String.valueOf(traceId==null?"":traceId);
    }
}
